package io.github.jianjianghui.groot.spring.boot;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * groot 配置
 *
 * @author <a href="https://www.github.com/jianjianghui">Jianghui Jian<a/>
 * @date 2021/8/27 - 16:22
 */
@ConfigurationProperties(prefix = "jjh.web.groot")
public class GrootProperties {

    /**
     * 启用幂等
     */
    private boolean enable = false;

    /**
     * 幂等头标识
     */
    private String headerTag = "requestId";

    /**
     * 幂等头标识不存在(非法)
     */
    private String headerTagNotFound = "幂等头标识不存在";

    /**
     * 幂等头标识内容非法(非法)
     */
    private String headerTagIllegalContent = "幂等头标识内容非法";

    /**
     * 幂等头拦截(被拦截)
     */
    private String headerTagVerificationFailed = "请求被拦截";

    /**
     * 存储器
     */
    private MemoryUnitEnum memoryUnit = MemoryUnitEnum.LOCAL;

    private RedisMemoryUnit redisMemoryUnit = new RedisMemoryUnit();

    private LocalMemoryUnit localMemoryUnit = new LocalMemoryUnit();

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public String getHeaderTag() {
        return headerTag;
    }

    public void setHeaderTag(String headerTag) {
        this.headerTag = headerTag;
    }

    public String getHeaderTagNotFound() {
        return headerTagNotFound;
    }

    public void setHeaderTagNotFound(String headerTagNotFound) {
        this.headerTagNotFound = headerTagNotFound;
    }

    public String getHeaderTagIllegalContent() {
        return headerTagIllegalContent;
    }

    public void setHeaderTagIllegalContent(String headerTagIllegalContent) {
        this.headerTagIllegalContent = headerTagIllegalContent;
    }

    public String getHeaderTagVerificationFailed() {
        return headerTagVerificationFailed;
    }

    public void setHeaderTagVerificationFailed(String headerTagVerificationFailed) {
        this.headerTagVerificationFailed = headerTagVerificationFailed;
    }

    public MemoryUnitEnum getMemoryUnit() {
        return memoryUnit;
    }

    public void setMemoryUnit(MemoryUnitEnum memoryUnit) {
        this.memoryUnit = memoryUnit;
    }

    public RedisMemoryUnit getRedisMemoryUnit() {
        return redisMemoryUnit;
    }

    public void setRedisMemoryUnit(RedisMemoryUnit redisMemoryUnit) {
        this.redisMemoryUnit = redisMemoryUnit;
    }

    public LocalMemoryUnit getLocalMemoryUnit() {
        return localMemoryUnit;
    }

    public void setLocalMemoryUnit(LocalMemoryUnit localMemoryUnit) {
        this.localMemoryUnit = localMemoryUnit;
    }

    public static class RedisMemoryUnit {
        String preKey = "jjh:groot:";

        public String getPreKey() {
            return preKey;
        }

        public void setPreKey(String preKey) {
            this.preKey = preKey;
        }
    }

    public static class LocalMemoryUnit {
        int asyncCoreSize = 1024;

        public int getAsyncCoreSize() {
            return asyncCoreSize;
        }

        public void setAsyncCoreSize(int asyncCoreSize) {
            this.asyncCoreSize = asyncCoreSize;
        }
    }


}
